package fylder.recycler.demo.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.ButterKnife;
import fylder.recycler.demo.R;

/**
 * 分离出footerLay的配置
 * <p/>
 * Created by fylder on 2015/11/24.
 */
public class TestAdapter extends BaseRecyclerAdapter {

    Context context;
    LayoutInflater inflater;

    int size = 0;

    public TestAdapter(Context context) {
        super(context);
        this.context = context;
        inflater = LayoutInflater.from(context);
    }


    public void refresh(int c) {
        this.size = c;
        STATS = STATS_EMPTY;
        notifyDataSetChanged();
    }

    public void loading() {
        STATS = STATS_LOADING;
        notifyDataSetChanged();
    }

    public void ending(int c) {
        this.size = c;
        STATS = STATS_END;
        notifyDataSetChanged();
    }

    @Override
    RecyclerView.ViewHolder createExcludeViewHolder(ViewGroup parent, int viewType) {
        return new DemoViewHolder(inflater.inflate(R.layout.item_view, parent, false));
    }

    @Override
    void onBindView(RecyclerView.ViewHolder holder, int position) {

    }

    @Override
    public int getItemCountExcludeView() {
        return size;
    }

    @Override
    public int getItemViewTypeExcludeExtraView(int realItemPosition) {
        return 1;
    }

    class DemoViewHolder extends RecyclerView.ViewHolder {

        public DemoViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
